<?php
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";


//echo  "CmbModulo =" . $_REQUEST["CmbModulo"] . "<br>";
//echo  "CmbCategoria =" . $_REQUEST["CmbCategoria"] . "<br>";
//echo  "CmbSubCategoria =" . $_REQUEST["CmbSubCategoria"] . "<br>";
//echo  "Hidid1 =" & $_REQUEST["Hidid1"] . "<br>";
//echo  "opc =" . $_REQUEST ["opc"] . "<br>";


//  '*****************************
//  'N I V E L    4
//  '***************************** 

switch ($_REQUEST["opc"]) {
    case 1:
    case 2:
//                  'Empresa
        $strid3=$arrData3[0][1];
        break;

    case 3:
//              'SubCategoria 
        $strid3=$_REQUEST["CmbSubCategoria"];
        break;
    default:
        $strid3=$arrData3[0][1];
        break;
}

if ($_REQUEST["opc"]=="G") {
    $strid3=$_REQUEST["CmbSubCategoria"];
    $ds3=$_REQUEST["ds3"];
}

$strSql="select a.id4,a.des,b.duracion, c.des from solotb_nivel4 a left join tramite_tiempo b on a.id4 = b.id_tramite left join tiempo c on b.unidad_tiempo = c.id";
$strSql .=" order by a.des";

//'   response.write strSql& "<br>"
SoloFun_ExecSql ($strSql,$arrData4);



//  '*****************************
//  'Elegir el maximo del 4 nivel
//  '***************************** 
$strSql="select (max(id4)+1) as id  from solotb_nivel4";

$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"], 
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);

if(!$oConexion->EjecutarQuery($strSql)) {

//   set ObjCons=Server.CreateObject("ADODB.Recordset")
//   ObjCons.Open strSql,session("SoloConn")

    $oConexion->getErrorMessage();
    $strERROR=1;
    $err=0;
}
$MaxId=$oConexion->getData("NUM");
$MaxId=$MaxId[0][0];
//   $MaxId=ObjCons.fields(0)
if (is_null($MaxId)) {
    $MaxId=($strid3*100)+1;
}
//   set ObjCons=nothing
$oConexion->Cerrar();

$soloSQL = "select id,des from tiempo";
soloFun_ExecSQL ($soloSQL,$SoloArrTiempo);
$StrCboTiempo = SoloFun_CargaCombo($SoloArrTiempo,"cmbTiempo","",$cmbTiempo," style='width: 80px' class='SoloStyle_Texto'","");

?>

<html>
    <head>
        <title>Documentacion</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
        <SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT></head>

    <body topmargin=0 leftmargin=0>
        <!-- Include File="includes/trn_header.asp" -->	
        <p align="center" class="SoloStyle_TituloPaginas">Tabla de Tr&aacute;mites</p>
        <form name="frmIngreso" action="trn_GrabaSubCategoria2.php" method="POST">
            <table border="0" width="50%" align="center">
                <tr> 
                    <td class="SoloStyle_Etiqueta">C&oacute;digo</td>
                    <td><input name="hidId1" type="text" class="SoloStyle_Texto" value="<?php echo $MaxId;?>" size="40" readonly></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Nuevo Tr&aacute;mite</td>
                    <td><input name="ATxtDesc" type="text" class="SoloStyle_Texto" id="ATxtDesc" size="40" maxlenght="50"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Duraci&oacute;n</td>
                    <td>
                        <input name="txtTiempo" type="text" class="SoloStyle_Texto" id="txtTiempo" size="20" maxlenght="2" value="15">
                        <?php echo $StrCboTiempo;?>
                    </td>
                </tr>
            </table>
            <br><center>
                <input type="button" name="CmdGrabar" value="Grabar" class="SoloStyle_Boton" onClick="SoloFun_Submit(document.frmIngreso)"></center>
            <input type="hidden" name="opc" value="G">
        </form>
        <table width="50%" border="0" align="center">
            <tr class="SoloStyle_Etiqueta">
                <td class="texto">Tr&aacute;mite</td>
                <td class="texto">Duraci&oacute;n</td>
                <td width="20%" class="texto">Acci&oacute;n</td>
            </tr>
            <?php for ($i=0;$i < count($arrData4);$i++) {
                $clase = "SoloStyle_Grid";
                if($i%2 > 0)
                    $clase = "SoloStyle_Texto";
                ?>

            <tr class="<?php echo $clase;?>">
                <td><?php echo $arrData4[$i][1];?></td>
                <td><?php echo $arrData4[$i][2]." ".$arrData4[$i][3];?></td>
                <td><a href="trn_GrabaSubCategoria2.php?id4=<?php echo $arrData4[$i][0];?>&ds4=<?php echo $arrData4[$i][1];?>&opc=M">
                        <img src='iconos/soloico_modificar.gif' alt='Modificar' width="23" height="19" border='0' style='cursor:pointer' ></a>&nbsp;
                    <a href="#" onClick="Comprobar('trn_GrabaSubCategoria2.php?id4=<?php echo $arrData4[$i][0];?>&ds4=<?php echo $arrData4[$i][1];?>&opc=E')">
                        <img src='iconos/soloico_eliminar.gif' alt='Borrar Campos' width="23" height="19" border='0' style='cursor:pointer'></a>&nbsp;
                </td>		 
            </tr>
                <?php }?>
        </table>
    </body>
</html>
<!--#include file="Includes/soloFun_ShowMessages.php"-->


<SCRIPT type="text/JavaScript" src="PHPMailer/fun_generales.js"></SCRIPT>
<!-- include file="includes/error.inc"-->
<script type="text/JavaScript">
    function Comprobar(pagina){
        var conf = confirm("Confirma Eliminar");
        if (conf)
            window.location.href = pagina;

    }

</script>